import java.io.File;

import trigest.trigest;


public class distHashTable {
	
	public static void main(String[] args) {
		trigest d1 = null;
		trigest d2 = null;
		int[] vertex_1 = new int[4];
		
		try{
			d1=new trigest("thank");			
		}
		catch (Exception e)
		{
			System.out.println("--- In exception ---");
		}
		
		//printbary(d1.getSignature());
		/*
		//System.out.println(" --- Now printing File Signature --- ");
		try {
			d2=new trigest(new File("C:\\Temp\\test.txt"));
			
		}
		catch (Exception e)
		{
			System.out.println(" In exception");			
		}*/
		//printbary(d2.getSignature());
		vertex_1=hashTable(d1.getSignature());
		for(int i=0;i<4;i++)
		System.out.println(vertex_1[i]);
       


	}
	

	public static int[] hashTable(byte[] hash) {
		
		int[] vertex = new int[4];
		int h=0;
		int iter=(hash.length/4)-1;
		int i=0;
		for(int j=0;j<4;j++)
		{ h=0;
		for ( i=j*iter; i < j*iter + iter;i++){//bary.length; i++) {
			
			
			//System.out.println(i);
			int t1=hash[i];
			String temp="";//="0000000";
			String t=Integer.toBinaryString(t1);
			int len=t.length();
			
			if(len==1)
			temp="0000000"; //System.out.println("im here");}
			else if(len==2)
			    temp="000000";
			else if(len==3)
			    temp="00000";
			else if(len==4)
			    temp="0000";
			else if(len==5)
			    temp="000";
			else if(len==6)
			    temp="00";
			else if(len==7)
			    temp="0";
		
		
			//System.out.println(temp2.length());
			
			temp=temp.concat(Integer.toBinaryString(t1));
			//System.out.println(temp2.length());
			//System.out.printf("%c%c%c%c%c%c%c%c ", temp.charAt(temp.length()-8),temp.charAt(temp.length()-7),temp.charAt(temp.length()-6),temp.charAt(temp.length()-5),temp.charAt(temp.length()-4),temp.charAt(temp.length()-3),temp.charAt(temp.length()-2),temp.charAt(temp.length()-1));
			
            //System.out.printf("im here");
			
			for(int k=8;k>0;k--)
			{
				if(temp.charAt(temp.length()-k)=='1')
					h++;
					//{System.out.println("wow we actually have a match!!!"); h++; }
				
			}
			
			
			//System.out.println("");
		}
		vertex[j]=h;
		//System.out.println("counter:"+h);
		System.out.println("counter:"+vertex[j]);
		//System.out.println("");
		
		//docRank(h);
		//return h;
		}
		return vertex;
	}

	
	

}
